package com.evil.application.api;

import com.evil.application.config.FeignErrorDecoder;
import com.evil.application.pojo.dto.*;
import com.evil.common.core.constant.ServiceNameConstant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 应用组接口
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@FeignClient(name = ServiceNameConstant.APPLICATION_SERVICE, configuration = {FeignErrorDecoder.class})
public interface RemoteApplicationService {

    /**
     * 应用列表
     *
     * @param applicationReqDTO applicationReqDTO
     */
    @PostMapping("/remote/application/list")
    List<ApplicationInfoRespDTO> applicationList(@Validated @RequestBody ApplicationReqDTO applicationReqDTO);

    /**
     * 应用基础信息列表
     *
     * @param applicationReqDTO applicationReqDTO
     */
    @PostMapping("/remote/application/bases")
    List<ApplicationBaseInfoRespDTO> applicationBases(@Validated @RequestBody ApplicationReqDTO applicationReqDTO);

    /**
     * 应用树
     *
     * @param applicationReqDTO applicationReqDTO
     */
    @PostMapping("/remote/application/tree")
    List<AppTreeDTO> applicationTree(@Validated @RequestBody ApplicationReqDTO applicationReqDTO);

    /**
     * 应用信息
     *
     * @param applicationKey 应用key
     */
    @PostMapping("/remote/application/info")
    ApplicationInfoRespDTO applicationInfo(@RequestParam("applicationKey") String applicationKey);

    /**
     * 应用基础信息
     *
     * @param applicationKey applicationKey
     * @return ApplicationBaseInfoRespDTO
     */
    @PostMapping("/remote/application/base-info")
    ApplicationBaseInfoRespDTO applicationBaseInfo(@RequestParam("applicationKey") String applicationKey);

    /**
     * 应用发布信息
     *
     * @param applicationKey applicationKey
     * @return ApplicationBaseInfoRespDTO
     */
    @PostMapping("/remote/application/publish-info")
    ApplicationPublishInfoRespDTO applicationPublishInfo(@RequestParam("applicationKey") String applicationKey);

    /**
     * 新增空白应用
     *
     * @param addApplicationReqDTO addApplicationReqDTO
     * @return ApplicationBaseInfoRespDTO
     */
    @PostMapping("/remote/application/add-empty")
    ApplicationBaseInfoRespDTO addApplication(@Validated @RequestBody AddApplicationReqDTO addApplicationReqDTO);

    /**
     * 编辑应用
     *
     * @param modifyApplicationReqDTO modifyApplicationReqDTO
     */
    @PostMapping("/remote/application/modify")
    void modifyApplication(@Validated @RequestBody ModifyApplicationReqDTO modifyApplicationReqDTO);

    /**
     * 编辑应用权限
     *
     * @param modifyApplicationPermissionReqDTO modifyAppPermissionReqDTO
     */
    @PostMapping("/remote/application/modify-permission")
    void modifyAppPermission(@Validated @RequestBody ModifyApplicationPermissionReqDTO modifyApplicationPermissionReqDTO);

    /**
     * 复制应用
     *
     * @param copyApplicationReqDTO copyApplicationReqDTO
     */
    @PostMapping("/remote/application/copy")
    void copyApplication(@Validated @RequestBody CopyApplicationReqDTO copyApplicationReqDTO);

    /**
     * 设为常用应用
     *
     * @param favouriteApplicationReqDTO favouriteApplicationReqDTO
     */
    @PostMapping("/remote/application/favourite")
    void favouriteApplication(@Validated @RequestBody FavouriteApplicationReqDTO favouriteApplicationReqDTO);

    /**
     * 常用应用列表
     */
    @PostMapping("/remote/application/favourite/list")
    List<ApplicationInfoDTO> favouriteApplicationList();

    /**
     * 删除应用
     *
     * @param applicationKey applicationKey
     */
    @PostMapping("/remote/application/delete")
    void deleteApplication(@RequestParam("applicationKey") String applicationKey);

    /**
     * 发布应用
     *
     * @param applicationKey applicationKey
     */
    @PostMapping("/remote/application/publish")
    void publishApplication(@RequestParam("applicationKey") String applicationKey);

    /**
     * 还原应用
     *
     * @param applicationKey applicationKey
     */
    @PostMapping("/remote/application/restore")
    void restoreApplication(@RequestParam("applicationKey") String applicationKey);

    /**
     * 编辑应用状态
     *
     * @param modifyApplicationStatusReqDTO modifyApplicationStatusReqDTO
     */
    @PostMapping("/remote/application/status/modify")
    void modifyApplicationStatus(@Validated @RequestBody ModifyApplicationStatusReqDTO modifyApplicationStatusReqDTO);

    /**
     * 编辑应用申请状态
     *
     * @param modifyApplicationApplyReqDTO modifyApplicationApplyReqDTO
     */
    @PostMapping("/remote/application/apply/modify")
    void modifyApplicationApply(@Validated @RequestBody ModifyApplicationApplyReqDTO modifyApplicationApplyReqDTO);
}
